<template>
  <PageWrapper title="订单详情" contentBackground contentClass="p-4" @back="goBack">
    <Description
      size="middle"
      title="基础信息"
      :bordered="false"
      :column="3"
      :data="orderData.data"
      :schema="orderSchema"
    />
  </PageWrapper>
</template>
<script lang="ts">
  import { defineComponent } from 'vue';
  import { PageWrapper } from '/@/components/Page';
  import { Description } from '/@/components/Description/index';
  import { useGo } from '/@/hooks/web/usePage';
  import { getDetail } from '/@/api/abc/order';
  import { useRouter } from 'vue-router';
  import { reactive } from 'vue';

  let orderData = reactive<any>({
    data: null,
  });

  export default defineComponent({
    components: { Description, PageWrapper },
    setup() {
      const go = useGo();
      const { currentRoute } = useRouter();

      function goBack() {
        go('/abc/index');
      }

      (async () => {
        const { blMerOrderNo } = currentRoute.value.query;
        if (blMerOrderNo) {
          const res = await getDetail({ blMerOrderNo: blMerOrderNo as string });
          orderData.data = res;
          console.log(res);
        }
      })();

      return {
        orderData,
        orderSchema: [
          {
            field: 'blMerOrderNo',
            label: '商户订单号',
          },
          {
            field: 'orderNo',
            label: '供应商端订单号',
          },
          {
            field: 'orderTime',
            label: '客户下单时间',
          },
          {
            field: 'orderState',
            label: '订单状态',
          },
          {
            field: 'businessType',
            label: '业务类型',
          },
          {
            field: 'rechargeAccount',
            label: '充值账号',
          },
          {
            field: 'extendAccount',
            label: '扩展账号',
          },
          {
            field: 'productId',
            label: '产品编号',
          },
          {
            field: 'provinceName',
            label: '省份',
          },
          {
            field: 'rechargeValue',
            label: '充值量',
          },
          {
            field: 'productSalePrice',
            label: '销售单价',
          },
          {
            field: 'productCost',
            label: '成本单价',
          },
          {
            field: 'profit',
            label: '利润',
          },
          {
            field: 'extendParam',
            label: '特殊充值内容',
          },
          {
            field: 'ispName',
            label: '运营商',
          },
        ],
        goBack,
      };
    },
  });
</script>
